package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.PriceStrategy;

/**
 * QPriceStrategy is a ORMLite query type for PriceStrategy
 * @see PriceStrategy
 */
public class QPriceStrategy extends QEntityBase<PriceStrategy> {

    public static final QPriceStrategy $ = new QPriceStrategy("PRICE_STRATEGY");

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public final Column name = field("name").columnName("NAME").varchar(32).notNull().build();

    public final Column description = field("description").columnName("DESCRIPTION").varchar(128).build();

    public final Column effectiveTime = field("effectiveTime").columnName("EFFECTIVE_TIME").localDateTime().notNull().build();

    public final Column expireTime = field("expireTime").columnName("EXPIRE_TIME").localDateTime().build();

    public class Indexs {

        public final Index constraintIndex9 = index("CONSTRAINT_INDEX_9").column(templateId).build();

        public final Index primaryKey9 = index("PRIMARY_KEY_9").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint9b = foreignKey(templateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QPriceStrategy(String tableName) {
        super(PriceStrategy.class, tableName);
    }

    @Override
    public PriceStrategy newInstance() {
        return new PriceStrategy();
    }

    @Override
    public Object getFieldValue(PriceStrategy instance, String fieldName) {
        switch (fieldName) {
            case "templateId":
                return instance.getTemplateId();
            case "name":
                return instance.getName();
            case "description":
                return instance.getDescription();
            case "effectiveTime":
                return instance.getEffectiveTime();
            case "expireTime":
                return instance.getExpireTime();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(PriceStrategy instance, String fieldName, Object value) {
        switch (fieldName) {
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            case "name":
                instance.setName((java.lang.String) value);
                break;
            case "description":
                instance.setDescription((java.lang.String) value);
                break;
            case "effectiveTime":
                instance.setEffectiveTime((java.time.LocalDateTime) value);
                break;
            case "expireTime":
                instance.setExpireTime((java.time.LocalDateTime) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

